<template>
  <div>
    <input type="text" ref="input">
    <button @click="getSearchData">搜索</button>
    <echarts2d v-if="search_data" :rela="search_data"></echarts2d>
  </div>
</template>

<script>
import {request} from '@/network/request'
import Echarts2d from '@/components/Echarts2d.vue'
  export default {
    name: 'search',
    components: {
        Echarts2d
    },
    data() {
        return {
            search_data: null
        }
    },
    methods: {
        async getSearchData() {
            const value = this.$refs.input.value.trim()
            if (!value) return alert('请先输入')
            const res = await request({ 
                url: '/search_name',
                params: {
                    name: value
                }
            })
            this.search_data = res
        }
    },
}
</script>

<style scoped>
  
</style>

